package com.sproutcat.sample;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.LockSupport;
import java.util.concurrent.locks.ReentrantLock;

public class ThreadStatusExample {

    private static Object obj1 = new Object();
    private static Lock lock = new ReentrantLock();

    public static void main(String[] args) throws InterruptedException {
        new Thread(() -> LockSupport.park(), "t1").start();

        new Thread(() -> LockSupport.park(TimeUnit.DAYS.toNanos(1)), "t2").start();

        lock.lock();
        new Thread(() -> {
            lock.lock();
            System.out.println("zzz222");
        }, "t3").start();

        new Thread(() -> {
            try {
                Thread.sleep(1000000000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "t4").start();

        synchronized (obj1) {
            new Thread(() -> {
                synchronized (obj1) {
                    System.out.println("zzz");
                }
            }, "t5").start();

            Thread.sleep(1000000000);
        }
    }

}
